package com.hd.contentmonitor.timer;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import com.hd.contentmonitor.service.WebContentMonitor;

public class ContentTimer {
    Timer timer;

    public ContentTimer() {
    	//Get the Date corresponding to 11:01:00 pm today.
    	Calendar calendar = Calendar.getInstance();
    	calendar.set(Calendar.HOUR_OF_DAY, 23);
    	calendar.set(Calendar.MINUTE, 30);
    	calendar.set(Calendar.SECOND, 0);
    	Date time = calendar.getTime();

    	timer = new Timer();
    	timer.schedule(new RemindTask(), time);
	}

    class RemindTask extends TimerTask {
        public void run() {
        	System.out.println("Task is going to be executed..");
        	WebContentMonitor webcontentMonitor = new WebContentMonitor();
            timer.cancel(); //Terminate the timer thread
        }
    }

    public static void main(String args[]) {
        new ContentTimer();
        System.out.format("Task scheduled.%n");
    }
}
